import * as code from "./config";
let config = {
    [code.NJXS]: "njxs.weilian.cn",
    [code.LNWSC]: "vmbase.scn.weilian.cn"
}


function initEnterpriseCode() {
    //如果sessionStorage里有了mg-enterpriseCode，则证明是后台管理系统，已经拿到了企业code
    // console.log("sessionStorage.getItem(mg-enterpriseCode)", sessionStorage.getItem("mg-enterpriseCode"));
    if (sessionStorage.getItem("mg-enterpriseCode")) {
        return sessionStorage.getItem("mg-enterpriseCode");
    }
    let url = window.location.href;
    // console.log("url,", url);
    let enterpriseCode;
    //宁家鲜生
    if (url.indexOf(config[code.NJXS]) > -1) {
    // if (url === config[code.NJXS]) {
        enterpriseCode = code.NJXS;
        // console.log("这是宁家商城");
        
        // console.log("sdssssss", "njxs")
    } 
    //李宁微商城
    else if (url.indexOf(config[code.LNWSC]) > -1) {
        enterpriseCode = code.LNWSC;
        // console.log("这是李宁商城");
        document.querySelector("head").querySelector("title").innerHTML = "李宁商城";
    } 
    //默认情况
    else {
        enterpriseCode = code.NJXS;
        // enterpriseCode = code.LNWSC;
    }
    // console.log("enter", enterpriseCode);
    return enterpriseCode;
}

export default initEnterpriseCode();